package com.lc.afbx.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.beans.BusinessType;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.scale.ScaleScreenHelper;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.List;

/**
 * Created by shenyuxin on 2016/12/26.
 */
public class BusinessTypeAdapter extends ArrayAdapter<BusinessType> {

    private LayoutInflater layoutInflater;
    private Context context;

    public BusinessTypeAdapter(Context context, List<BusinessType> lists) {

        super(context, 0, lists);

        layoutInflater = LayoutInflater.from(context);

        this.context = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        BusinessType businessType = getItem(position);

        ViewHolder holder;

        if (convertView == null) {

            convertView = BoundViewHelper.boundView(holder = new ViewHolder(), BaseApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_business_type_list, null)));

            convertView.setTag(holder);
        } else {

            holder = (ViewHolder) convertView.getTag();
        }

        holder.item_business_money_tv.setText(businessType.getMoney());
        holder.item_business_type_tv.setText(businessType.getType());



        return convertView;
    }

    class ViewHolder {

        @BoundView(R.id.item_business_type_tv) private TextView item_business_type_tv;

        @BoundView(R.id.item_business_money_tv) private TextView item_business_money_tv;
    }

}
